package com.gulimall.gulimallsearch.controller;

import com.gulimall.gulimallsearch.service.mallSearchService;
import com.gulimall.gulimallsearch.vo.SearchResult;
import com.gulimall.gulimallsearch.vo.SearchVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author mayifan
 * @version 1.0
 * @date 2024-12-24 12:44
 */
@Controller
public class SearchController {

    @Autowired
    mallSearchService mallSearchService;

    @GetMapping("/list.html")
    public String listPage(SearchVo vo, Model model, HttpServletRequest request){
        vo.set_queryString(request.getQueryString());
        SearchResult result = mallSearchService.search(vo);
        model.addAttribute("result",result);
        return "list";
    }
}
